package cn.spring.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.spring.bean.Commodity;
import cn.spring.bean.Type;
import cn.spring.dao.CommodityMapper;
import cn.spring.dao.TypeMapper;
import cn.spring.service.CommodityService;

@Service
@Transactional
public class CommodityServiceImpl implements CommodityService {

	@Resource
	private CommodityMapper dao;
	
	@Resource
	private TypeMapper tDao;
	
	@Override
	public List<Commodity> getAll(int typeid) {
		// TODO Auto-generated method stub
		return dao.getAll(typeid);
	}

	@Override
	public List<Map<String, Object>> findAll(int empId) {
		// TODO Auto-generated method stub
		return dao.findAll(empId);
	}

	@Override
	public List<Map<String, Object>> tong() {
		// TODO Auto-generated method stub
		return dao.tong();
	}

	@Override
	public int insert(Commodity com) {
		// TODO Auto-generated method stub
		return dao.insert(com);
	}

	@Override
	public int update(Commodity com) {
		// TODO Auto-generated method stub
		return dao.updateByPrimaryKeySelective(com);
	}

	@Override
	public Commodity findById(int id) {
		// TODO Auto-generated method stub
		return dao.selectByPrimaryKey(id);
	}

	@Override
	public List<Type> getType() {
		// TODO Auto-generated method stub
		return tDao.getAll();
	}

	@Override
	public int updateIsMai(Integer id) {
		// TODO Auto-generated method stub
		return dao.updateIsMai(id);
	}

	@Override
	public List<Map<String, Object>> findAllByContent(String key) {
		// TODO Auto-generated method stub
		key="%"+key+"%";
		return dao.findAllByContent(key);
	}

	@Override
	public List<Commodity> getAll1() {
		// TODO Auto-generated method stub
		return dao.getAll1();
	}

	@Override
	public int updateStatsById(Boolean isMai, int id) {
		// TODO Auto-generated method stub
		return dao.updateStatsById(isMai, id);
	}

	@Override
	public int updateIsMaiAll(Boolean isMai) {
		// TODO Auto-generated method stub
		return dao.updateIsMaiAll(isMai);
	}

	@Override
	public List<Map<String, Object>> tongShan() {
		// TODO Auto-generated method stub
		return dao.tongShan();
	}
	
	
}
